package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity2 extends AppCompatActivity {
    TextView tv1,tv2,tv3,tv4,tv5,tv6,tv7;
    private TextView tv_ip1,tv_ip2,tv_ip3,tv_ip4,tv_ip5,tv_ip6,tv_ip7;
    Button btn_update,btn_exit;
    ImageView image_avatar;
    //String value1,value2,value3,value4,value5,value6,value7;
    String value2,value3,value4,value5,value6,value7;
    int k;
    int[] image_avatars = new int[]{
            R.drawable.touxiang1,
            R.drawable.touxiang2
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btn_update();
        btn_exit();
    }
    private void initView() {
        tv1=findViewById(R.id.textView_name);
        tv2=findViewById(R.id.textView_sex);
        tv3=findViewById(R.id.textView_address);
        tv4=findViewById(R.id.textView_birthday);
        tv5=findViewById(R.id.textView_constellation);
        tv6=findViewById(R.id.textView_signature);
        tv7=findViewById(R.id.textView_favorite);
        tv_ip1=findViewById(R.id.textView_input_name);
        tv_ip2=findViewById(R.id.textView_input_sex);
        tv_ip3=findViewById(R.id.textView_input_address);
        tv_ip4=findViewById(R.id.textView_input_birthday);
        tv_ip5=findViewById(R.id.textView_input_constellation);
        tv_ip6=findViewById(R.id.textView_input_signature);
        tv_ip7=findViewById(R.id.textView_input_favorite);
        image_avatar=findViewById(R.id.imageView_avatar);
        //传值
        Intent intent = getIntent();
        String value = intent.getStringExtra("name");
        value2 = intent.getStringExtra("sex");
        value3 = intent.getStringExtra("address");
        value4 = intent.getStringExtra("birthday");
        value5 = intent.getStringExtra("constellation");
        value6 = intent.getStringExtra("signature");
        value7 = intent.getStringExtra("favorite");
        k=intent.getIntExtra("image",0);
        image_avatar.setBackgroundResource(image_avatars[k]);
        tv_ip1.setText(value);
        tv_ip2.setText(value2);
        tv_ip3.setText(value3);
        tv_ip4.setText(value4);
        tv_ip5.setText(value5);
        tv_ip6.setText(value6);
        tv_ip7.setText(value7);

        btn_update=findViewById(R.id.button_update);
        btn_exit=findViewById(R.id.button_exit);
    }
    private void btn_update() {
        btn_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent1 = new Intent();
                intent1.setClass(MainActivity2.this,MassageActivity1.class);
                startActivity(intent1);
            }
        });
    }
    private void btn_exit() {
        btn_exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent2 = new Intent();
                intent2 = intent2.setClass(MainActivity2.this,MassageActivity1.class);
                startActivity(intent2);
                //finish();
            }
        });
    }
}